package com.bdv.md.model;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table (name = "DM_TBL")
@DynamicInsert
@DynamicUpdate
public class DmTbl extends BaseObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2L;
	
	private String dmId;
	private String balanceKWH;
	private String totalUsage;
	private String voltageR;
	private String voltageS;
	private String voltageT;
	private String arusR;
	private String arusS;
	private String arusT;
	private String powerFactor;
	private String dayaInstant;
	private String tarifIndex;
	private String statusTamper;
	private String totalOff;
	private String prediksiKreditHabis;
	private Integer paymentModeMeterType;
	private String sudutI;
	private String sudutV;
	private String sudutR;
	private String firmware;
	private Timestamp timeStamp;
	private Integer tipeReading;
	private String alertLimBalance;
	private String alertIsiToken;
	private String noToken;
	private String nilaiToken;
	private String tipeAlert;
	private String powerStatus;
	private MapTbl mapTbl;
	
	private long timeInNumber;
	
	
	public DmTbl(){}
	
	public DmTbl(Integer tipeReading) {
		this.tipeReading = tipeReading;
	}
	
	/**
	 * Constructor for Report Data Meter
	 */
	public DmTbl(String balanceKWH, String totalUsage, String voltageR,
			String voltageS, String voltageT, String arusR, String arusS,
			String arusT, String powerFactor, String dayaInstant,
			String tarifIndex, String statusTamper,/* String totalOff,*/
			String prediksiKreditHabis, Integer paymentModeMeterType,
			String sudutI, String sudutV, String sudutR, String firmware,
			long timeInNumber) {
		this.balanceKWH = balanceKWH;
		this.totalUsage = totalUsage;
		this.voltageR = voltageR;
		this.voltageS = voltageS;
		this.voltageT = voltageT;
		this.arusR = arusR;
		this.arusS = arusS;
		this.arusT = arusT;
		this.powerFactor = powerFactor;
		this.dayaInstant = dayaInstant;
		this.tarifIndex = tarifIndex;
		this.statusTamper = statusTamper;
		//this.totalOff = totalOff;
		this.prediksiKreditHabis = prediksiKreditHabis;
		this.paymentModeMeterType = paymentModeMeterType;
		this.sudutI = sudutI;
		this.sudutV = sudutV;
		this.sudutR = sudutR;
		this.firmware = firmware;
		this.timeInNumber = timeInNumber;
	}

	public DmTbl( String balanceKWH, String totalUsage, String voltageR,
			String voltageS, String voltageT, String arusR, String arusS,
			String arusT, String powerFactor, String dayaInstant,
			String tarifIndex, String statusTamper,/* String totalOff,*/
			String prediksiKreditHabis, Integer paymentModeMeterType,
			String sudutI, String sudutV, String sudutR, String firmware,
			Timestamp timeStamp, MapTbl mapTbl) {
		this.balanceKWH = balanceKWH;
		this.totalUsage = totalUsage;
		this.voltageR = voltageR;
		this.voltageS = voltageS;
		this.voltageT = voltageT;
		this.arusR = arusR;
		this.arusS = arusS;
		this.arusT = arusT;
		this.powerFactor = powerFactor;
		this.dayaInstant = dayaInstant;
		this.tarifIndex = tarifIndex;
		this.statusTamper = statusTamper;
		//this.totalOff = totalOff;
		this.prediksiKreditHabis = prediksiKreditHabis;
		this.paymentModeMeterType = paymentModeMeterType;
		this.sudutI = sudutI;
		this.sudutV = sudutV;
		this.sudutR = sudutR;
		this.firmware = firmware;
		this.timeStamp = timeStamp;
		this.mapTbl = mapTbl;
	}


	public DmTbl(String balanceKWH, String statusTamper, Timestamp timeStamp,
			Integer tipeReading, String alertLimBalance, String alertIsiToken,
			String noToken, String nilaiToken, String tipeAlert,
			String powerStatus, MapTbl mapTbl) {
		this.balanceKWH = balanceKWH;
		this.statusTamper = statusTamper;
		this.timeStamp = timeStamp;
		this.tipeReading = tipeReading;
		this.alertLimBalance = alertLimBalance;
		this.alertIsiToken = alertIsiToken;
		this.noToken = noToken;
		this.nilaiToken = nilaiToken;
		this.tipeAlert = tipeAlert;
		this.powerStatus = powerStatus;
		this.mapTbl = mapTbl;
	}
	

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "DM_ID")
	public String getDmId() {
		return dmId;
	}
	public void setDmId(String dmId) {
		this.dmId = dmId;
	}
	@Column(name = "BALANCE_KWH")
	public String getBalanceKWH() {
		return balanceKWH;
	}
	public void setBalanceKWH(String balanceKWH) {
		this.balanceKWH = balanceKWH;
	}
	@Column(name = "TOTAL_USAGE")
	public String getTotalUsage() {
		return totalUsage;
	}
	public void setTotalUsage(String totalUsage) {
		this.totalUsage = totalUsage;
	}
	@Column(name = "POWER_FACTOR")
	public String getPowerFactor() {
		return powerFactor;
	}
	public void setPowerFactor(String powerFactor) {
		this.powerFactor = powerFactor;
	}
	@Column(name = "DAYA_INSTANT")
	public String getDayaInstant() {
		return dayaInstant;
	}
	public void setDayaInstant(String dayaInstant) {
		this.dayaInstant = dayaInstant;
	}
	@Column(name = "TARIF_INDEX")
	public String getTarifIndex() {
		return tarifIndex;
	}
	public void setTarifIndex(String tarifIndex) {
		this.tarifIndex = tarifIndex;
	}
	@Column(name = "STATUS_TAMPER")
	public String getStatusTamper() {
		return statusTamper;
	}
	public void setStatusTamper(String statusTamper) {
		this.statusTamper = statusTamper;
	}
	@Column(name = "TOTAL_OFF")
	public String getTotalOff() {
		return totalOff;
	}
	public void setTotalOff(String totalOff) {
		this.totalOff = totalOff;
	}
	@Column(name = "PREDIKSI_KREDIT_HABIS")
	public String getPrediksiKreditHabis() {
		return prediksiKreditHabis;
	}
	public void setPrediksiKreditHabis(String prediksiKreditHabis) {
		this.prediksiKreditHabis = prediksiKreditHabis;
	}
	@Column(name = "PAYMENT_MODE_METER_TYPE")
	public Integer getPaymentModeMeterType() {
		return paymentModeMeterType;
	}
	public void setPaymentModeMeterType(Integer paymentModeMeterType) {
		this.paymentModeMeterType = paymentModeMeterType;
	}
	@Column(name = "FIRMWARE")
	public String getFirmware() {
		return firmware;
	}
	public void setFirmware(String firmware) {
		this.firmware = firmware;
	}
	@Column(name = "TIME_STAMP")
	public Timestamp getTimeStamp() {
		return timeStamp;
	}
	public void setTimeStamp(Timestamp timeStamp) {
		this.timeStamp = timeStamp;
	}
	@Column(name = "TIPE_READING")
	public Integer getTipeReading() {
		return tipeReading;
	}
	public void setTipeReading(Integer tipeReading) {
		this.tipeReading = tipeReading;
	}
	@Column(name = "ALERT_LIM_BALANCE")
	public String getAlertLimBalance() {
		return alertLimBalance;
	}
	public void setAlertLimBalance(String alertLimBalance) {
		this.alertLimBalance = alertLimBalance;
	}
	@Column(name = "ALERT_ISI_TOKEN")
	public String getAlertIsiToken() {
		return alertIsiToken;
	}
	public void setAlertIsiToken(String alertIsiToken) {
		this.alertIsiToken = alertIsiToken;
	}
	@Column(name = "NO_TOKEN")
	public String getNoToken() {
		return noToken;
	}
	public void setNoToken(String noToken) {
		this.noToken = noToken;
	}
	@Column(name = "NILAI_TOKEN")
	public String getNilaiToken() {
		return nilaiToken;
	}
	public void setNilaiToken(String nilaiToken) {
		this.nilaiToken = nilaiToken;
	}
	@Column(name = "TIPE_ALERT")
	public String getTipeAlert() {
		return tipeAlert;
	}
	public void setTipeAlert(String tipeAlert) {
		this.tipeAlert = tipeAlert;
	}
	@Column(name = "POWER_STATUS")
	public String getPowerStatus() {
		return powerStatus;
	}
	public void setPowerStatus(String powerStatus) {
		this.powerStatus = powerStatus;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MAP_ID", nullable = false)
	public MapTbl getMapTbl() {
		return mapTbl;
	}
	public void setMapTbl(MapTbl mapTbl) {
		this.mapTbl = mapTbl;
	}

	@Column(name = "VOLTAGE_R")
	public String getVoltageR() {
		return voltageR;
	}

	public void setVoltageR(String voltageR) {
		this.voltageR = voltageR;
	}

	@Column(name = "VOLTAGE_S")
	public String getVoltageS() {
		return voltageS;
	}

	public void setVoltageS(String voltageS) {
		this.voltageS = voltageS;
	}

	@Column(name = "VOLTAGE_T")
	public String getVoltageT() {
		return voltageT;
	}

	public void setVoltageT(String voltageT) {
		this.voltageT = voltageT;
	}

	@Column(name = "ARUS_R")
	public String getArusR() {
		return arusR;
	}

	public void setArusR(String arusR) {
		this.arusR = arusR;
	}

	@Column(name = "ARUS_S")
	public String getArusS() {
		return arusS;
	}

	public void setArusS(String arusS) {
		this.arusS = arusS;
	}

	@Column(name = "ARUS_T")
	public String getArusT() {
		return arusT;
	}

	public void setArusT(String arusT) {
		this.arusT = arusT;
	}


	@Column(name = "SUDUT_I")
	public String getSudutI() {
		return sudutI;
	}


	public void setSudutI(String sudutI) {
		this.sudutI = sudutI;
	}


	@Column(name = "SUDUT_V")
	public String getSudutV() {
		return sudutV;
	}


	public void setSudutV(String sudutV) {
		this.sudutV = sudutV;
	}


	@Column(name = "SUDUT_R")
	public String getSudutR() {
		return sudutR;
	}


	public void setSudutR(String sudutR) {
		this.sudutR = sudutR;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((alertIsiToken == null) ? 0 : alertIsiToken.hashCode());
		result = prime * result
				+ ((alertLimBalance == null) ? 0 : alertLimBalance.hashCode());
		result = prime * result + ((arusR == null) ? 0 : arusR.hashCode());
		result = prime * result + ((arusS == null) ? 0 : arusS.hashCode());
		result = prime * result + ((arusT == null) ? 0 : arusT.hashCode());
		result = prime * result
				+ ((balanceKWH == null) ? 0 : balanceKWH.hashCode());
		result = prime * result
				+ ((dayaInstant == null) ? 0 : dayaInstant.hashCode());
		result = prime * result + ((dmId == null) ? 0 : dmId.hashCode());
		result = prime * result
				+ ((firmware == null) ? 0 : firmware.hashCode());
		result = prime * result
				+ ((nilaiToken == null) ? 0 : nilaiToken.hashCode());
		result = prime * result + ((noToken == null) ? 0 : noToken.hashCode());
		result = prime
				* result
				+ ((paymentModeMeterType == null) ? 0 : paymentModeMeterType
						.hashCode());
		result = prime * result
				+ ((powerFactor == null) ? 0 : powerFactor.hashCode());
		result = prime * result
				+ ((powerStatus == null) ? 0 : powerStatus.hashCode());
		result = prime
				* result
				+ ((prediksiKreditHabis == null) ? 0 : prediksiKreditHabis
						.hashCode());
		result = prime * result
				+ ((statusTamper == null) ? 0 : statusTamper.hashCode());
		result = prime * result + ((sudutI == null) ? 0 : sudutI.hashCode());
		result = prime * result + ((sudutR == null) ? 0 : sudutR.hashCode());
		result = prime * result + ((sudutV == null) ? 0 : sudutV.hashCode());
		result = prime * result
				+ ((tarifIndex == null) ? 0 : tarifIndex.hashCode());
		result = prime * result
				+ ((timeStamp == null) ? 0 : timeStamp.hashCode());
		result = prime * result
				+ ((tipeAlert == null) ? 0 : tipeAlert.hashCode());
		result = prime * result
				+ ((tipeReading == null) ? 0 : tipeReading.hashCode());
		result = prime * result
				+ ((totalOff == null) ? 0 : totalOff.hashCode());
		result = prime * result
				+ ((totalUsage == null) ? 0 : totalUsage.hashCode());
		result = prime * result
				+ ((voltageR == null) ? 0 : voltageR.hashCode());
		result = prime * result
				+ ((voltageS == null) ? 0 : voltageS.hashCode());
		result = prime * result
				+ ((voltageT == null) ? 0 : voltageT.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DmTbl other = (DmTbl) obj;
		if (alertIsiToken == null) {
			if (other.alertIsiToken != null)
				return false;
		} else if (!alertIsiToken.equals(other.alertIsiToken))
			return false;
		if (alertLimBalance == null) {
			if (other.alertLimBalance != null)
				return false;
		} else if (!alertLimBalance.equals(other.alertLimBalance))
			return false;
		if (arusR == null) {
			if (other.arusR != null)
				return false;
		} else if (!arusR.equals(other.arusR))
			return false;
		if (arusS == null) {
			if (other.arusS != null)
				return false;
		} else if (!arusS.equals(other.arusS))
			return false;
		if (arusT == null) {
			if (other.arusT != null)
				return false;
		} else if (!arusT.equals(other.arusT))
			return false;
		if (balanceKWH == null) {
			if (other.balanceKWH != null)
				return false;
		} else if (!balanceKWH.equals(other.balanceKWH))
			return false;
		if (dayaInstant == null) {
			if (other.dayaInstant != null)
				return false;
		} else if (!dayaInstant.equals(other.dayaInstant))
			return false;
		if (dmId == null) {
			if (other.dmId != null)
				return false;
		} else if (!dmId.equals(other.dmId))
			return false;
		if (firmware == null) {
			if (other.firmware != null)
				return false;
		} else if (!firmware.equals(other.firmware))
			return false;
		if (nilaiToken == null) {
			if (other.nilaiToken != null)
				return false;
		} else if (!nilaiToken.equals(other.nilaiToken))
			return false;
		if (noToken == null) {
			if (other.noToken != null)
				return false;
		} else if (!noToken.equals(other.noToken))
			return false;
		if (paymentModeMeterType == null) {
			if (other.paymentModeMeterType != null)
				return false;
		} else if (!paymentModeMeterType.equals(other.paymentModeMeterType))
			return false;
		if (powerFactor == null) {
			if (other.powerFactor != null)
				return false;
		} else if (!powerFactor.equals(other.powerFactor))
			return false;
		if (powerStatus == null) {
			if (other.powerStatus != null)
				return false;
		} else if (!powerStatus.equals(other.powerStatus))
			return false;
		if (prediksiKreditHabis == null) {
			if (other.prediksiKreditHabis != null)
				return false;
		} else if (!prediksiKreditHabis.equals(other.prediksiKreditHabis))
			return false;
		if (statusTamper == null) {
			if (other.statusTamper != null)
				return false;
		} else if (!statusTamper.equals(other.statusTamper))
			return false;
		if (sudutI == null) {
			if (other.sudutI != null)
				return false;
		} else if (!sudutI.equals(other.sudutI))
			return false;
		if (sudutR == null) {
			if (other.sudutR != null)
				return false;
		} else if (!sudutR.equals(other.sudutR))
			return false;
		if (sudutV == null) {
			if (other.sudutV != null)
				return false;
		} else if (!sudutV.equals(other.sudutV))
			return false;
		if (tarifIndex == null) {
			if (other.tarifIndex != null)
				return false;
		} else if (!tarifIndex.equals(other.tarifIndex))
			return false;
		if (timeStamp == null) {
			if (other.timeStamp != null)
				return false;
		} else if (!timeStamp.equals(other.timeStamp))
			return false;
		if (tipeAlert == null) {
			if (other.tipeAlert != null)
				return false;
		} else if (!tipeAlert.equals(other.tipeAlert))
			return false;
		if (tipeReading == null) {
			if (other.tipeReading != null)
				return false;
		} else if (!tipeReading.equals(other.tipeReading))
			return false;
		if (totalOff == null) {
			if (other.totalOff != null)
				return false;
		} else if (!totalOff.equals(other.totalOff))
			return false;
		if (totalUsage == null) {
			if (other.totalUsage != null)
				return false;
		} else if (!totalUsage.equals(other.totalUsage))
			return false;
		if (voltageR == null) {
			if (other.voltageR != null)
				return false;
		} else if (!voltageR.equals(other.voltageR))
			return false;
		if (voltageS == null) {
			if (other.voltageS != null)
				return false;
		} else if (!voltageS.equals(other.voltageS))
			return false;
		if (voltageT == null) {
			if (other.voltageT != null)
				return false;
		} else if (!voltageT.equals(other.voltageT))
			return false;
		return true;
	}


	@Override
	public String toString() {
		return "DmTbl [dmId=" + dmId + ", balanceKWH=" + balanceKWH
				+ ", totalUsage=" + totalUsage + ", voltageR=" + voltageR
				+ ", voltageS=" + voltageS + ", voltageT=" + voltageT
				+ ", arusR=" + arusR + ", arusS=" + arusS + ", arusT=" + arusT
				+ ", powerFactor=" + powerFactor + ", dayaInstant="
				+ dayaInstant + ", tarifIndex=" + tarifIndex
				+ ", statusTamper=" + statusTamper + ", totalOff=" + totalOff
				+ ", prediksiKreditHabis=" + prediksiKreditHabis
				+ ", paymentModeMeterType=" + paymentModeMeterType
				+ ", sudutI=" + sudutI + ", sudutV=" + sudutV + ", sudutR="
				+ sudutR + ", firmware=" + firmware + ", timeStamp="
				+ timeStamp + ", tipeReading=" + tipeReading
				+ ", alertLimBalance=" + alertLimBalance + ", alertIsiToken="
				+ alertIsiToken + ", noToken=" + noToken + ", nilaiToken="
				+ nilaiToken + ", tipeAlert=" + tipeAlert + ", powerStatus="
				+ powerStatus + ", mapTbl=" + mapTbl + "]";
	}

	@Transient
	public long getTimeInNumber() {
		return timeInNumber;
	}

	public void setTimeInNumber(long timeInNumber) {
		this.timeInNumber = timeInNumber;
	}


}
